﻿using System.Collections.Generic;
using System.Xml;
using Calculator.Xroad.Eu;
using Calculator.Xroad.Eu.Messages;
using Xtee.Core.Envelope;
using Xtee.XteeClient.Calculator;

namespace Xtee.Calc.Impl
{
    public class CalculatorAdapterWrapper : CalculatorAdapter
    {
        public virtual AddResponse Add(Variables request, string version)
        {
            var addInputHeader = new global::Calculator.Xroad.Eu.Headers.AddInputHeader();
            addInputHeader.Client = XteeCommand.Configuration.Client;
            addInputHeader.Service = Service;
            addInputHeader.Service.ServiceCode = "Add";
            addInputHeader.Service.ServiceVersion = version;
            addInputHeader.Id = Xtee.Core.Utils.StringUtils.GenerateNonce();
            addInputHeader.ProtocolVersion = this.ProtocolVersion;
            addInputHeader.UserId = XteeCommand.Configuration.UserId;
            addInputHeader.Issue = XteeCommand.Configuration.Issue;
            global::Xtee.Core.Envelope.ISoapEnvelope responseEnvelope = XteeCommand.Execute(new global::Xtee.Core.Envelope.SoapEnvelope(new XmlQualifiedName("tns", "http://calculator.x-road.eu"),new List<XmlQualifiedName>(),  "Add", addInputHeader, new global::Calculator.Xroad.Eu.Messages.AddRequest(request)));
            return ((global::Calculator.Xroad.Eu.Messages.AddResponse)(responseEnvelope.Body));
        }
    }
}
